filename.txt |
Re: want to extract particular values from a text file using dxl regExp Regexp regexpInitialMatch = regexp2 "<PASSEDATTRIBUTES>" Regexp regexpEndMatch = regexp2 "</PASSEDATTRIBUTES>" Regexp regxpName = regexp2 "Name" string sEachline = null string sCollectAttri = null string sdsfFile = "C:\\Documents and Settings\\user\\Desktop\\Example.txt" Stream streamIn = read sdsfFile Buffer bufTempStoreAttri = create string ExtractPassbackAttr(string sdsfFile ) { while (true) { streamIn >>sEachline if(end streamIn) { break } elseif(regexpInitialMatch sEachline ) { streamIn >>sEachline while(!regexpEndMatch sEachline) { if (!regxpName sEachline) { bufTempStoreAttri = bufTempStoreAttri""sEachline"\n" } streamIn >>sEachline } } } return stringOf(bufTempStoreAttri) close (streamIn) } sCollectAttri = ExtractPassbackAttr(sdsfFile) if (null sCollectAttri ) { print "No Attributes Passed back from Supplier" } else { print sCollectAttri } delete bufTempStoreAttri /*********************************************************/ Is there any other way to optimize this pgm? |
Re: want to extract particular values from a text file using dxl regExp umeshaKrishnegowda - Mon Jan 21 06:00:01 EST 2013
I'm guessing that you will NOT do any better performance wise with some single grand Regexp that would look something like this:
I'm sure the above re is incorrect; and I am NOT sure you can realistically program a single one; due to the EOLs embedded in the string. In any case, the 3 "(.*)" will probably need to be replaces with some code that means "any ascii character except EOL. -Louie |